<template>
	<view class="user-item" @tap="clickUser(user)">
		<view class="image">
			<image :src="user.headimgurl" mode=""></image>
		</view>
		<view class="text">
			<view class="name">{{user.name || user.nickname}}</view>
			<view class="newmsg" v-if="type === 1">{{user.last_butt_msg}}</view>
		</view>
		<view class="tips">
			<view class="badge" v-if="user.new_num">{{user.new_num ? (user.new_num > 99 ? '99+' : user.new_num) : 0}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			user: {
				type: Object,
				default: {}
			},
			type: {
				type: Number,
				default: 1
			}
		},
		methods: {
			clickUser (user) {
				this.$emit('clickUser', user)
			}
		}
	}
</script>

<style>
	@import './style.css';
</style>
